package robotAPI;

public class RobotReplyMessage {
	private int moveReq = 0, moveReal = 0;
	private int rotateReq = 0, rotateReal = 0;
	private boolean reboot = false;
	private int nScan = 0;
	private int scanValue[];

	public RobotReplyMessage(int mReq, int mReal, int rReq, int rReal, int n,
			int scan[], boolean r) {
		moveReq = mReq;
		moveReal = mReal;
		rotateReq = rReq;
		rotateReal = rReal;
		nScan = n;
		scanValue = scan;
		reboot = r;
	}

	public int getMoveReal() {
		return moveReal;
	}

	public int getMoveReq() {
		return moveReq;
	}

	public boolean notMoveEqual() {
		return moveReq == moveReal;
	}

	public int getRotateReal() {
		return rotateReal;
	}

	public int getRotateReq() {
		return rotateReq;
	}

	public boolean notRotateEqual() {
		return rotateReq == rotateReal;
	}

	public boolean didReboot() {
		return reboot;
	}

	public int getNumScan() {
		return nScan;
	}

	public boolean hasScanValues() {
		if (scanValue == null)
			return false;
		else
			return true;
	}

	public int getScanValueN(int n) {
		return scanValue[n];
	}

	public String toString() {
		StringBuilder result = new StringBuilder();
		result.append(this.getClass().getName() + ": \n");
		if (notMoveEqual()) {
			result.append("\tWas requested to drive " + moveReq + " but drove "
					+ moveReal + ".\n");
		} else {
			result.append("\tDrove " + moveReal + "cm.\n");
		}
		if (notRotateEqual()) {
			result.append("\tWas requested to rotate " + rotateReq
					+ " but rotated " + rotateReal + ".\n");
		} else {
			result.append("\tRotated " + rotateReal + "cm.\n");
		}
		result.append("\tScanned in " + nScan + "direction: \n");
		for (int i = 0; i < nScan; i++) {
			result.append("\t\tResult " + (i + 1) + ": " + scanValue[i] + "\n");
		}
		if (reboot) {
			result.append("Robot rebooted!\n");
		}
		return result.toString();
	}
}
